//搜索插入位置
package Leetcode;

class solution_035 {
	public int searchInsert(int[] nums, int target) {
		if (nums.length == 1)
			return nums[0] < target ? 1 : 0;
		int left = 0;
		int right = nums.length - 1;
		while (left <= right) {
			int mid = (left + right)/2;
			if (nums[mid] == target)
				return mid;
			else if (nums[mid] > target)
				right = mid - 1;
			else
				left = mid + 1;
		}
		return left;
	}
}

public class Solution035 {

}
